package com.xin.data.simbapesa.adapter;

import android.text.Layout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.xin.data.simbapesa.R;
import com.xin.data.simbapesa.base.BaseBindingAdapter1;
import com.xin.data.simbapesa.databinding.SimbaCsItemBinding;
import com.xin.data.simbapesa.obj.SimbaCustomerService;
import com.xin.data.simbapesa.utils.ResUtils;
import com.xin.data.simbapesa.utils.ViewUtils;

import java.util.List;

public class CsAdapter extends BaseBindingAdapter1<SimbaCustomerService, SimbaCsItemBinding> {


    public CsAdapter(List<SimbaCustomerService> dataList) {
        super(dataList);
    }

    @Override
    protected void bindData(SimbaCsItemBinding binding, SimbaCustomerService item, int position) {

        binding.tvSubTitle.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NONE);


        binding.tvTitle.setText(ResUtils.s(R.string.cs_item_title, String.valueOf(position + 1)));

        if (item.isPhone()) {
            binding.tvBtn.setVisibility(View.VISIBLE);
        } else {
            binding.tvBtn.setVisibility(View.GONE);
        }
        binding.tvBtn.setOnClickListener(v -> {
            ViewUtils.viewScale(v);
            if (onBtnItemClickListener != null) {
                onBtnItemClickListener.onItemClick(position);
            }
        });
        binding.tvSubTitle.setText(item.getData());

        if (position == dataList.size() - 1) {
            binding.tvLine.setVisibility(View.GONE);
        } else {
            binding.tvLine.setVisibility(View.VISIBLE);
        }


    }

    @Override
    protected int getItemType(SimbaCustomerService item) {
        return 0;
    }

    @Override
    protected SimbaCsItemBinding createBinding(LayoutInflater inflater, ViewGroup parent, int viewType) {
        return SimbaCsItemBinding.inflate(inflater, parent, false);
    }


}
